/*
 *  $Id: CardPhrase.cs 896 2009-11-27 11:19:29Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008-2009 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Languages {
    /// <summary>
    /// Класс, создающий при первом обращении фразу по карте и суффиксу.
    /// </summary>
    public class CardPhrase<T> where T: Card {
        private string _suffix;
        private Phrase _phrase;

        public CardPhrase(string suffix) {
            _suffix = suffix;
            _phrase = null;
        }

        public Phrase Phrase {
            get {
                if (_phrase == null) {
                    Card card = CardManager.GetCard<T>();
                    string id = card != null ? card.GetResourceId(_suffix) : Card.CardPrefix+_suffix;
                    _phrase = new Phrase(id);
                }
                return _phrase;
            }
        }

        public override string ToString() {
            return Phrase.GetText();
        }
    }
}
